<?php
declare (strict_types=1);

namespace app\common\model;

class ProductCate extends Base
{

    public static function getAll()
    {
        try {

            $result = parent::where('is_del', 0)->order('sort', 'asc')->select()->toArray();
            return mergeMenu($result);

        } catch (\Exception $e) {
            return [];
        }
    }

    public static function getCate($id = 0)
    {
        return parent::where(['pid' => $id, 'is_del' => 0, 'status' => 1])->field('id,title')->select();
    }


    public function getIconAttr($value)
    {
        return handleImg($value);
    }


    public static function writeLog($logs)
    {
        Logs::adds('修改商品分类 -- 标识ID【' . $logs['model']->id . '】', $logs['admin']->id, $logs['admin']->admin_name);
    }

}
